An external routine (External Routine) is generally a program that is compiled by using an advanced programming language and may be embedded in a structured query language (SQL) statement. Source code of the external routine, after being compiled, may be invoked by a database management system, so that a database function is extended. A database system includes a database and a database management system, where the database is used to store data, and the database management system is used to operate, manage, and maintain the database. Generally, the database management system may be a structured query language database management system (MySQL) and so on, and the database may be a structured query language database (SQL Server), an Oracle database (Oracle), and so on, and the database provides extensive support for the advanced programming language, where the advanced programming language may be a C language, a C++ language, a JAVA language, a Common Business Oriented Language (COBOL), and so on.
In the prior art, the database system may compile, by using an embedded database management system and an embedded extended language compiling module, the source code of the external routine compiled by using the advanced programming language, to obtain target code of the external routine, where the database management system may be a MySQL, Teradata, and so on, and the extended language compiling module may be a DB2, a PostgreSQL, and so on. Then, the target code of the external routine is stored to the database according to a target name and target address set by a user, where the target name is used to uniquely identify the target code of the external routine, and the target address is used to identify an address of the target code of the external routine stored in the database, so that the target code of the external routine is invoked according to the target name and the target address. Alternatively, after the source code of the external routine is compiled by using a programming tool of the advanced programming language, the target code of the external routine is copied to the database according to the target name and target address set by the user, and it is necessary to register information such as the target name and target address with the database, so that the database management system identifies and invokes the target code of the external routine.
However, central processors on different operating platforms are different, and instruction sets of different central processors are also different. Therefore, the external routine compiled by using the advanced programming language, when running on different operating platforms, needs to be compiled by different compilers to obtain target code of the external routine which is suitable for running on a current operating platform, where the operating platform is hardware and/or software required for running the target code of the external routine. The instruction set is used to convert the external routine into the target code of the external routine which is suitable for running on the operating platform. For example, when an external routine is compiled into target code of an x86 version, the target code can only run on a central processor that supports an x86 instruction set. Therefore, different compilers need to be embedded into the database system to compile the source code of the external routine, which limits scalability of the database system, and a security problem exists when the external routine is compiled.